<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <script type="text/javascript">
         function userEdit(obj){
			    var ob = $(obj);
				var userStatus=ob.children().first().text();
				var userId=ob.parent().parent().parent().children().first().next().next().text();
				ob.userId=userId;
				ob.userStatus=userStatus;
				var abc={};
				abc.userId=userId;
				abc.userStatus=userStatus;
				$.post('user/userStatus.do',abc,edit,'json');
		}
		function edit(date){
			var userId=date.id;
			var status=date.stu;
			if(status!=1){
			$('#'+userId+'').children().first().text(0);
			$('#'+userId+'').children().last().text('启用');}
			if(status==1){
			$('#'+userId+'').children().first().text(1);
			$('#'+userId+'').children().last().text('禁用');}
		}
    </script>
  </head>
  
  <body>
     <form id="pagerForm" method="post" action="<%=basePath%>user/manager.do">
		<input type="hidden" name="pageNum" value="${requestScope.count.pageNum}" />
		<input type="hidden" name="numPerPage" value="${requestScope.count.numPerPage}" />
		<input type="hidden" name="userName" value="${requestScope.count.userName}" />
		<input type="hidden" name="userId" value="${requestScope.count.userId}" />
		<input type="hidden" name="userDeptName" value="${requestScope.count.userDeptName}" />
	</form>
	<div class="pageHeader" id="">
		<form onsubmit="return navTabSearch(this);" action="<%=basePath%>user/manager.do" method="post">
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>
						用户名：<input type="text" name="userName" value="${requestScope.count.userName}"/>
					</td>
					<td>
						用户编号：<input type="text" name="userId" value="${requestScope.count.userId}"/>
					</td>
					<td>
						部门：<input bringbackname="district.deptid"  value="" type="hidden"/>
					<input class="required" bringbackname="district.deptname" type="text" name="userDeptName"  value="${requestScope.count.userDeptName}" readonly/>
					</td>
					<td><a class="btnLook" href="<%=basePath%>dept/showtree.do" lookupGroup="district">查找带回</a></td>
				</tr>
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
				</ul>
			</div>
		</div>
		</form>
	</div>
	<div class="pageContent">
		<div class="panelBar">
			<ul class="toolBar">
				<li><a class="add" href="user/add.do" target="navTab" width="800" height="400"><span>添加</span></a></li>
				<li><a class="delete" href="user/delete.do" target="selectedTodo" title="确定要删除吗?" rel="click"><span>删除</span></a></li>
				<li class="line">line</li>
			</ul>
		</div>
		<div id='usertable'>
		<table  class="table" width="100%" layoutH="138">
			<thead>
				<tr>
				    <th width="20"></th>
				    <th width="10"></th>
					<th width="120">用户编号</th>
					<th width="100">用户名</th>
					<th width="100">用户部门</th>
					<th width="150">电话</th>
					<th width="80" align="center">邮箱</th>
					<th width="80">用户等级</th>
					<th width="80">用户类型</th>
					<th width="80">状态</th>
					<th width="80">操作</th>
					<th width="80"></th>
				</tr>
			</thead>
			<tbody>
		    <c:forEach items="${requestScope.userList}" var="user" varStatus="count">
		    <tr>
		        <td width="15">${count.index+1}</td>
		        <td width="10">
		        <input type="checkbox" name="click" value="${user.userId}"/>
		        </td>
	            <td width="120">${user.userId}</td>
	            <td width="100">${user.userName}</td>
	            <td width="100">${user.userDeptName}</td>
	            <td width="150">${user.phone}</td>
	            <td width="80">${user.email}</td>
	            <td width="80">${user.userLevel}</td>
	            <td width="80">${user.userType}</td>
	            <c:if test="${user.userStatus eq 1}"><td width="80">
	            <a href="javascript:void(0)" onclick="userEdit(this)" id="${user.userId}" ><span style="display: none">${user.userStatus}</span><span style="color: blue">禁用</span></a></td></c:if>
	            <c:if test="${user.userStatus eq 0}"><td width="80">
	            <a href="javascript:void(0)"  onclick="userEdit(this)" id="${user.userId}" ><span  style="display: none">${user.userStatus}</span><span style="color: blue">启用</span></a></td></c:if>
	            <c:if test="${empty user.userStatus}"><td width="80">
	            <a href="javascript:void(0)" onclick="userEdit(this)" id="${user.userId}" ><span  style="display: none">${user.userStatus}</span><span style="color: blue">启用</span></a></td></c:if>
	           <td><a href="user/role.do?userId=${user.userId}" target="dialog"><span style="color:blue">关联角色</span></a></td>
	           <td width="80"><a href="user/edit.do?userId=${user.userId}" target="dialog" rel="edituser"><span style="color:blue">修改</span></a></td>
	            </tr>
		    </c:forEach>
			</tbody>
		</table>
	
	</div>
	  
		<!-- 用来绘制分页的界面 -->
		
			<div class="panelBar">
			<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" 
	
	onchange="navTabPageBreak({numPerPage:this.value})">
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="50">50</option>
				</select>
				<span>条，共${requestScope.count.totalCount}条</span>
			</div>
			<div class="pagination" targetType="navTab" totalCount="${requestScope.count.totalCount}" numPerPage="${requestScope.count.numPerPage}" pageNumShown="5" currentPage="${requestScope.count.pageNum}"></div>
		</div>
		
	</div>
  </body>
</html>


